/**  
 * @Title: GameCommentController.java
 * @Package com.limit.control.admin
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-3 上午10:34:50
 * @version V1.0
 */ 
package com.limit.control.admin;

import java.util.Date;

import com.jfinal.aop.Before;
import com.limit.control.admin.validate.GameCommentValidator;
import com.limit.model.GameComment;

/** 
 * <br/>
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-3 上午10:34:50 
 * @version V1.0
 */

public class GameCommentController extends BaseController {

	/**
	 * 主页
	 */
	public void index(){
		int pageNow = this.getParaToInt("p", 1);
		long game_id = this.getParaToLong("game_id",0L);
		this.setAttr("game_comments", GameComment.dao.paginateList(game_id,pageNow,pageSize));
		
		this.setAttr("game_id", game_id);
		this.render("game_comments.html");
	}
	
	public void view(){
		this._commonSetId();
		long game_id = this.getParaToLong("game_id", 0L);
		GameComment game_comment = new GameComment();
		if(id > 0){
			game_comment = GameComment.dao.findById(id);
		}
		this.setAttr("gameComment", game_comment);
		this.setAttr("game_id", game_id);
		this.render("game_comment_view.html");
		
	}
	
	
	@Before(GameCommentValidator.class)
	public void save(){
		long game_id = this.getParaToLong("game_id", 0L);
		this.getModel(GameComment.class)
			.set("create_time", new Date())
			.set("game_id", game_id).save();
		this.index();
	}
	
	@Before(GameCommentValidator.class)
	public void update(){
		this.getModel(GameComment.class,"gameComment").update();
		this.index();
	}
	
	/**
	 * 显示
	 */
	public void check(){
		this._commonSetId();
		GameComment.dao.findById(id).set("is_check", 1).update();
		this.index();
	}
	
	/**
	 * 不显示
	 */
	public void nocheck(){
		this._commonSetId();
		GameComment.dao.findById(id).set("is_check", -1).update();
		this.index();
	}
}
